{% extends 'rebs/layouts/base.html' %}

{% load static widget_tweaks humanize %}

{% block title %}Rebs - 계약 내역 조회{% endblock %}

{% block content %}

    <!-- Start Content-->
    <div class="container-fluid">

        <!-- start page title -->
        {% include 'rebs/partials/content_title.html' with  second_bs="분양 계약 관리" title="계약 현황 조회" %}
        <!-- end page title -->

        <div class="row">
            <form class="form-horizontal p-0 col-12" name="form1" method="get">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">

                            {% with menu_order='1' %}
                                {% include 'rebs_contract/partials/head_menu.html' %}
                            {% endwith %}

                            <div class="row">
                                {% include 'rebs/partials/project_select.html' %}
                                <div class="col-sm-12 col-md-6"></div>
                            </div>
                            <div class="row">
                                {% include 'rebs_contract/partials/contract_summary.html' %}
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body pb-1">
                            <div class="row mb-3 bg-light">

                                {% include 'rebs_contract/partials/list_search_form.html' %}

                            </div>

                            <div class="row">
                                {% include 'rebs_contract/partials/contract_table.html' %}
                            </div>

                            {% if is_paginated %}

                                {# to_first_last :: 맨처음 / 맨끝으로 버튼 사용 여부 #}
                                {# page_class ex:: pagination-rounded pagination-sm pagination-lg justify-content-center justify-content-end #}
                                {% include 'partials/pagination.html' with to_first_last="ok" page_class="pagination-rounded justify-content-end" %}

                            {% endif %}

                            <div class="row mt-4">
                                <div class="col-12 m-0 p-0 accordion custom-accordion" id="custom-accordion-one">
                                    <div class="card mb-0">
                                        <div class="card-header" id="headingFive">
                                            <h5 class="m-0">
                                                <a class="custom-accordion-title collapsed d-block py-1"
                                                   data-toggle="collapse" href="#collapseFive"
                                                   aria-expanded="false" aria-controls="collapseFive">
                                                    <i class="dripicons-view-apps text-danger"></i> 청약 현황 <i
                                                        class="mdi mdi-chevron-down accordion-arrow"></i>
                                                </a>
                                            </h5>
                                        </div>
                                        <div id="collapseFive" class="collapse"
                                             aria-labelledby="headingFive"
                                             data-parent="#custom-accordion-one">
                                            <div class="card-body p-0">
                                                {% include 'rebs_contract/partials/reservation_table.html' %}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>

    </div> <!-- container -->

{% endblock %}

{% block third_party_js %}
    <script>
      const q = document.getElementById('id_q')

      window.onload = function () {
        document.getElementById('id_project_sel').setAttribute('onchange', 'submit()')

        document.getElementById('id_group').value = '{{ request.GET.group }}'
        document.getElementById('id_type').value = '{{ request.GET.type }}'
        document.getElementById('id_status').value = '{{ request.GET.status }}'
        document.getElementById('id_sdate').value = '{{ request.GET.sdate }}'
        document.getElementById('id_edate').value = '{{ request.GET.edate }}'
        document.getElementById('id_register').value = '{{ request.GET.register }}'
        q.value = '{{ request.GET.q }}'
        q.setAttribute('onclick', 'this.value=\'\'')
      }
    </script>
{% endblock %}
